﻿@model OrderModel
@inject Grand.Services.Security.IPermissionService permissionService
@{
    //page title
    ViewBag.Title = T("Admin.Orders.EditOrderDetails").Text;
    //has "Manage Documents" permission?
    var canManageDocuments = await permissionService.Authorize(Grand.Services.Security.StandardPermissionProvider.ManageDocuments);
    var canManageGenericAttributes = await permissionService.Authorize(Grand.Services.Security.StandardPermissionProvider.ManageGenericAttributes);
}
<form asp-area="@Constants.AreaAdmin" asp-controller="Order" asp-action="Edit" method="post" id="order-form">
    
    <div class="row">
        <div class="col-md-12">
            <div class="x_panel light form-fit">
                <div class="x_title">
                    <div class="caption">
                        <i class="icon-basket"></i>
                        @T("Admin.Orders.EditOrderDetails") - @Model.OrderNumber
                        <small><i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(T("Admin.Orders.BackToList").Text, "List")</small>
                    </div>
                    <div class="actions">
                        <div class="btn-group btn-group-devided util-btn-margin-bottom-5">
                            <a href="@Url.Action("PdfInvoice", new { orderId = Model.Id })" class="btn purple">
                                <i class="fa fa-file-pdf-o"></i> @T("Admin.Orders.PdfInvoice")
                            </a>
                            @if (!Model.IsLoggedInAsVendor)
                            {
                                <span id="order-delete" class="btn red"><i class="fa fa-trash-o"></i> @T("Admin.Common.Delete")</span>
                            }
                            <input type="submit" id="btnRefreshPage" style="display: none" />
                            <script>
                                $(document).ready(function () {
                                    $('#btnRefreshPage').click(function () {
                                        //refresh page
                                        location.reload();
                                    });
                                });
                            </script>
                            <vc:admin-widget widget-zone="order_details_buttons" additional-data="Model" />
                        </div>
                    </div>
                </div>
                <div class="x_content form">
                    <admin-tabstrip name="order-edit" SetTabPos="true">
                        <items>
                            <tabstrip-item text="@T("Admin.Orders.Info")" tab-index="0">
                                <content>
                                    <div>
                                        <partial name="_OrderDetails.Info" model="Model" />
                                    </div>
                                </content>
                            </tabstrip-item>

                            <tabstrip-item text="@T("Admin.Orders.Addresses")" tab-index="1">
                                <content>
                                    <div>
                                        <partial name="_OrderDetails.Addresses" model="Model" />
                                    </div>
                                </content>
                            </tabstrip-item>
                            <tabstrip-item text="@T("Admin.Orders.Shipments")" tab-index="2">
                                <content>
                                    <div>
                                        <partial name="_OrderDetails.Shipment" model="Model" />
                                    </div>
                                </content>
                            </tabstrip-item>
                            <tabstrip-item text="@T("Admin.Orders.Products")" tab-index="3">
                                <content>
                                    <div>
                                        <partial name="_OrderDetails.Products" model="Model" />
                                    </div>
                                </content>
                            </tabstrip-item>
                            @if (!Model.IsLoggedInAsVendor)
                            {
                                <tabstrip-item text="@T("Admin.Orders.OrderNotes")" tab-index="4">
                                    <content>
                                        <div>
                                            <partial name="_OrderDetails.Notes" model="Model" />
                                        </div>
                                    </content>
                                </tabstrip-item>
                            }
                            @if (canManageDocuments)
                            {
                                <tabstrip-item text="@T("Admin.Orders.Documents")" tab-index="5">
                                    <content>
                                        <div>
                                            <partial name="_OrderDetails.Documents" model="Model" />
                                        </div>
                                    </content>
                                </tabstrip-item>
                            }
                            @if (canManageGenericAttributes)
                            {
                                <tabstrip-item text="@T("Admin.Common.GenericAttributes.Tab")" tab-index="6">
                                    <content>
                                        <div>
                                            <div class="form-actions">
                                                <input type="submit" value="@T("Admin.Common.Save")" id="btnSaveGenericAttributes" name="save-generic-attributes" class="k-button" />
                                            </div>
                                            <div class="form-horizontal">
                                                @{
                                                    ViewData["ObjectType"] = "Order";
                                                    ViewData["TabIndex"] = 5;
                                                }
                                                <partial name="_GenericAttributes" model="Model" view-data="ViewData" />
                                            </div>
                                        </div>
                                    </content>
                                </tabstrip-item>
                            }
                            <vc:admin-widget widget-zone="order_details_tabs" additional-data="Model" />
                        </items>
                    </admin-tabstrip>
                </div>
            </div>
        </div>
    </div>
    <div asp-validation-summary="All"></div>

</form>
<admin-delete-confirmation button-id="order-delete" />
